<extend name="Common@Layout:layui-admin" />
<block name="title">
    <title>编辑公众文章</title>
</block>
<block name="style">
    <css href="/Public/umeditor/themes/default/css/umeditor.css" />
    <style>
        {
            -ms-text-size-adjust: 100%;
            -webkit-text-size-adjust: 100%;
            line-height: 1.6
        }
        
        {
            -webkit-touch-callout: none;
            font-family: -apple-system-font, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
            background-color: #f3f3f3;
            line-height: inherit
        }
        
        rich_media_empty_extra {
            background-color: #fff
        }
        
        rich_media_empty_extra .rich_media_area_primary:before {
            display: none
        }
        
        h1,
        h2,
        h3,
        h4,
        h5,
        h6 {
            font-weight: 400;
            font-size: 16px
        }
        
        * {
            margin: 0;
            padding: 0
        }
        
        a {
            color: #607fa6;
            text-decoration: none
        }
        
        .rich_media_inner {
            font-size: 16px;
            word-wrap: break-word;
            -webkit-hyphens: auto;
            -ms-hyphens: auto;
            hyphens: auto
        }
        
        .rich_media_area_primary {
            position: relative;
            padding: 20px 15px 15px;
            background-color: #fff
        }
        
        .rich_media_area_primary:before {
            content: " ";
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 1px;
            border-top: 1px solid #e5e5e5;
            -webkit-transform-origin: 0 0;
            transform-origin: 0 0;
            -webkit-transform: scaleY(0.5);
            transform: scaleY(0.5);
            top: auto;
            bottom: -2px
        }
        
        .rich_media_area_primary .original_img_wrp {
            display: inline-block;
            font-size: 0
        }
        
        .rich_media_area_primary .original_img_wrp .tips_global {
            display: block;
            margin-top: .5em;
            font-size: 14px;
            text-align: right;
            width: auto;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            word-wrap: normal
        }
        
        .rich_media_area_extra {
            padding: 0 15px 0
        }
        
        .rich_media_title {
            line-height: 1.4;
            font-weight: 400;
            font-size: 24px;
            padding-bottom: 10px;
            margin-bottom: 14px;
            border-bottom: 1px solid #e7e7eb;
        }
        
        .rich_media_meta_list {
            margin-bottom: 18px;
            line-height: 20px;
            font-size: 0
        }
        
        .rich_media_meta_list em {
            font-style: normal
        }
        
        .rich_media_meta {
            display: inline-block;
            vertical-align: middle;
            margin-right: 8px;
            margin-bottom: 10px;
            font-size: 16px
        }
        
        .meta_original_tag {
            display: inline-block;
            vertical-align: middle;
            padding: 1px .5em;
            border: 1px solid #9e9e9e;
            color: #8c8c8c;
            border-top-left-radius: 20% 50%;
            -moz-border-radius-topleft: 20% 50%;
            -webkit-border-top-left-radius: 20% 50%;
            border-top-right-radius: 20% 50%;
            -moz-border-radius-topright: 20% 50%;
            -webkit-border-top-right-radius: 20% 50%;
            border-bottom-left-radius: 20% 50%;
            -moz-border-radius-bottomleft: 20% 50%;
            -webkit-border-bottom-left-radius: 20% 50%;
            border-bottom-right-radius: 20% 50%;
            -moz-border-radius-bottomright: 20% 50%;
            -webkit-border-bottom-right-radius: 20% 50%;
            font-size: 15px;
            line-height: 1.1
        }
        
        .meta_enterprise_tag img {
            width: 30px;
            height: 30px!important;
            display: block;
            position: relative;
            margin-top: -3px;
            border: 0
        }
        
        .rich_media_meta_text {
            color: #8c8c8c
        }
        
        span.rich_media_meta_nickname {
            display: none
        }
        
        .rich_media_thumb_wrp {
            margin-bottom: 6px
        }
        
        .rich_media_thumb_wrp .original_img_wrp {
            display: block
        }
        
        .rich_media_thumb {
            display: block;
            width: 100%
        }
        
        .edui-body-container {
            overflow: hidden;
            color: #3e3e3e
        }
        
        .edui-body-container * {
            max-width: 100%!important;
            box-sizing: border-box!important;
            -webkit-box-sizing: border-box!important;
            word-wrap: break-word!important
        }
        
        .edui-body-container p {
            clear: both;
            min-height: 1em
        }
        
        .edui-body-container em {
            font-style: italic
        }
        
        .edui-body-container fieldset {
            min-width: 0
        }
        
        .edui-body-container .list-paddingleft-2 {
            padding-left: 30px
        }
        
        .edui-body-container blockquote {
            margin: 0;
            padding-left: 10px;
            border-left: 3px solid #dbdbdb
        }
        
        img {
            height: auto!important
        }
        
        @media screen and (device-aspect-ratio:2/3),
        screen and (device-aspect-ratio:40/71) {
            .meta_original_tag {
                padding-top: 0
            }
        }
        
        @media(min-device-width:375px) and (max-device-width:667px) and (-webkit-min-device-pixel-ratio:2) {
            .mm_appmsg .rich_media_inner,
            .mm_appmsg .rich_media_meta,
            .mm_appmsg .discuss_list,
            .mm_appmsg .rich_media_extra,
            .mm_appmsg .title_tips .tips {
                font-size: 17px
            }
            .mm_appmsg .meta_original_tag {
                font-size: 15px
            }
        }
        
        @media(min-device-width:414px) and (max-device-width:736px) and (-webkit-min-device-pixel-ratio:3) {
            .mm_appmsg .rich_media_title {
                font-size: 25px
            }
        }
        
        @media screen and (min-width:1024px) {
            .rich_media {
                width: 740px;
                margin-left: auto;
                margin-right: auto
            }
            .rich_media_inner {
                padding: 20px
            }
            body {
                background-color: #fff
            }
        }
        
        @media screen and (min-width:1025px) {
            body {
                font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif
            }
            .rich_media {
                position: relative
            }
            .rich_media_inner {
                background-color: #fff;
                padding-bottom: 100px
            }
        }
        
        .radius_avatar {
            display: inline-block;
            background-color: #fff;
            padding: 3px;
            border-radius: 50%;
            -moz-border-radius: 50%;
            -webkit-border-radius: 50%;
            overflow: hidden;
            vertical-align: middle
        }
        
        .radius_avatar img {
            display: block;
            width: 100%;
            height: 100%;
            border-radius: 50%;
            -moz-border-radius: 50%;
            -webkit-border-radius: 50%;
            background-color: #eee
        }
        
        .cell {
            padding: .8em 0;
            display: block;
            position: relative
        }
        
        .cell_hd,
        .cell_bd,
        .cell_ft {
            display: table-cell;
            vertical-align: middle;
            word-wrap: break-word;
            word-break: break-all;
            white-space: nowrap
        }
        
        .cell_primary {
            width: 2000px;
            white-space: normal
        }
        
        .flex_cell {
            padding: 10px 0;
            display: -webkit-box;
            display: -webkit-flex;
            display: -ms-flexbox;
            display: flex;
            -webkit-box-align: center;
            -webkit-align-items: center;
            -ms-flex-align: center;
            align-items: center
        }
        
        .flex_cell_primary {
            width: 100%;
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            -ms-flex: 1;
            box-flex: 1;
            flex: 1
        }
        
        .original_tool_area {
            display: block;
            padding: .75em 1em 0;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            color: #3e3e3e;
            border: 1px solid #eaeaea;
            margin: 20px 0
        }
        
        .original_tool_area .tips_global {
            position: relative;
            padding-bottom: .5em;
            font-size: 15px
        }
        
        .original_tool_area .tips_global:after {
            content: " ";
            position: absolute;
            left: 0;
            bottom: 0;
            right: 0;
            height: 1px;
            border-bottom: 1px solid #dbdbdb;
            -webkit-transform-origin: 0 100%;
            transform-origin: 0 100%;
            -webkit-transform: scaleY(0.5);
            transform: scaleY(0.5)
        }
        
        .original_tool_area .radius_avatar {
            width: 27px;
            height: 27px;
            padding: 0;
            margin-right: .5em
        }
        
        .original_tool_area .radius_avatar img {
            height: 100%!important
        }
        
        .original_tool_area .flex_cell_bd {
            width: auto;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            word-wrap: normal
        }
        
        .original_tool_area .flex_cell_ft {
            font-size: 14px;
            color: #8c8c8c;
            padding-left: 1em;
            white-space: nowrap
        }
        
        .original_tool_area .icon_access:after {
            content: " ";
            display: inline-block;
            height: 8px;
            width: 8px;
            border-width: 1px 1px 0 0;
            border-color: #cbcad0;
            border-style: solid;
            transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
            -ms-transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
            -webkit-transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
            position: relative;
            top: -2px;
            top: -1px
        }
        
        .rich_media_global_msg {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            padding: 1em 35px 1em 15px;
            z-index: 1;
            background-color: #c6e0f8;
            color: #8c8c8c;
            font-size: 13px
        }
        
        .rich_media_global_msg .icon_closed {
            position: absolute;
            right: 15px;
            top: 50%;
            margin-top: -5px;
            line-height: 300px;
            overflow: hidden;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            background: transparent url(/mmbizwap/zh_CN/htmledition/images/icon/appmsg/icon_appmsg_msg_closed_sprite.2x.png) no-repeat 0 0;
            width: 11px;
            height: 11px;
            vertical-align: middle;
            display: inline-block;
            -webkit-background-size: 100% auto;
            background-size: 100% auto
        }
        
        .rich_media_global_msg .icon_closed:active {
            background-position: 0 -17px
        }
        
        .preview_appmsg .rich_media_title {
            margin-top: 1.9em
        }
        
        @media screen and (min-width:1024px) {
            .rich_media_global_msg {
                position: relative;
                margin: 0 20px
            }
            .preview_appmsg .rich_media_title {
                margin-top: 0
            }
        }
        
        #refresh-btn {
            position: fixed;
            z-index: 3;
            top: 10px;
            right: 10px;
            border-radius: 8px;
            background-color: orange;
            font-size: 16px;
            text-align: center;
            padding: 5px 10px;
            color: #fff;
            white-space: nowrap;
        }
        
        .wxb-read-like {
            font-size: 12px;
            color: #999;
        }
        
        .wxb-read-like .fl {
            display: inline-block;
            padding: 5px 10px 5px 0px;
        }
        
        .wxb-read-like .fr {
            display: inline-block;
            float: right;
            padding: 5px 0px;
        }
        
        .wxb-musci-wrap {
            width: 100%;
            height: 30px;
            background-color: #ddd;
        }
        
        #activity-name {
            font-size: 20px;
            color: #333333;
            text-align: left;
        }
        
        #showTime,
        #author {
            font-size: 13px;
            color: #666666;
            text-align: left;
            margin-right: 10px;
        }
        
        #showWxb {
            font-size: 13px;
            color: #4979b1;
            text-align: left;
        }
    </style>
</block>

<block name="main">
    <div class="layui-main" style="width:auto">
        <form class="layui-form close-dialog" action="{:U('edit_post')}" method="post" style="margin-top:20px;">
            <div class="layui-form-item">
                <label class="layui-form-label">文章链接：</label>
                <div class="layui-input-block">
                    <input type="text" name="url" value="{$info.url}" id="url" lay-verify="required|url" placeholder="请输入公众号文章链接" autocomplete="off" class="layui-input" style="width:420px;display:inline-block;">
                    <a class="layui-btn" id="getcontent" style="margin-left:30px;">立即加载文章</a>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">标题：</label>
                <div class="layui-input-block">
                    <input type="text" name="title" value="{$info.title}" id="title" lay-verify="required" placeholder="请输入文章标题" autocomplete="off" class="layui-input" style="width:574px;display:inline-block;">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">作者：</label>
                    <div class="layui-input-block">
                        <input type="text" name="author" value="{$info.author}" id="author" placeholder="请输入作者" autocomplete="off" class="layui-input" style="width:200px;display:inline-block;">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">发布时间：</label>
                    <div class="layui-input-block">
                        <input type="text" name="wdate" value="{$info.wdate}" id="wdate" placeholder="请输入发布时间" autocomplete="off" class="layui-input" style="width:200px;display:inline-block;">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">详细：</label>
                <div class="layui-input-block">
                    <textarea id="myEditor" style="width:580px;height:240px;" name="content">{$info.content}</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="hidden" name="id" value="{$info.id}">
                    <button class="layui-btn" lay-submit lay-filter="*">立即提交</button>
                </div>
            </div>
        </form>
    </div>
</block>


<block name="script">
    <js href="/Public/umeditor/third-party/jquery.min.js,/Public/umeditor/third-party/template.min.js,/Public/umeditor/umeditor.config.js,/Public/umeditor/umeditor.min.js,/Public/umeditor/lang/zh-cn/zh-cn.js" />
    <script>
        //实例化编辑器
        var um = UM.getEditor('myEditor');

        $('#getcontent').click(function() {
            var wxurl = $('#url').val();
            if (wxurl == "") {
                layui.layer.alert('文章链接不能为空啊！');
                $('#url').focus();
            } else {
                var ii;
                $.ajax({
                    url: '/admin/wxcontent/get_wx_content?wxurl=' + wxurl,
                    type: "get",
                    dataType: "json",
                    beforeSend: function() {
                        ii = layer.msg('正在拉去文章数据，请稍等...', {
                            icon: 16,
                            time: 100000
                        });
                    },
                    complete: function() {
                        layer.close(ii);
                    },
                    success: function(data) {
                        if (data.status) {
                            layer.msg('拉去成功', {
                                icon: 1,
                                time: 1000
                            }, function() {
                                var ret = data.data;
                                $('#url').val(ret.url);
                                $('#title').val(ret.title);
                                $('#author').val(ret.author);
                                $('#wdate').val(ret.wdate);
                                um.execCommand('insertHtml', ret.content);
                            });
                        } else {
                            layer.msg(data.info, {
                                icon: 2,
                                time: 1000
                            });
                        }
                    }
                });
            }
        });
    </script>
</block>